/**
 * 
 */
$(function(){
	//toggleMenu();
	adaptive();
	//renderICkeck();
	$("#modelIdentCodeList").attr("disabled","disabled");
	$("#systemCodeList").attr("disabled","disabled");
	$("#subSystemCodeList").attr("disabled","disabled");
	$("#assyCodeList").attr("disabled","disabled");
	$("#infoCodeList").attr("disabled","disabled");
	//获取查询的条件
	/*$("#searchWords").val($(window.parent.document).find("#search1").val());
	$("#searchType").val($(window.parent.document).find("#search2").val());
	$("#pmCode").val($(window.parent.document).find("#search3").val());
	$("#modelIdentCode").val($(window.parent.document).find("#search4").val());
	$("#systemCode").val($(window.parent.document).find("#search5").val());
	$("#subSystemCode").val($(window.parent.document).find("#search6").val());
	$("#assyCode").val($(window.parent.document).find("#search7").val());
	$("#infoCode").val($(window.parent.document).find("#search8").val());
	$("#username").val($(window.parent.document).find("#search9").val());*/
	
	// 获取搜索范围（项目列表）
	$.ajax({
		url:'/ietm/getProjectId',
		success:function(data){
			 for(var i in data.projects){             
		            $("#projectList").append("<option value="+data.projects[i].pmcCode+">"+data.projects[i].pmcCode+"</option>");
		        }
			}
	});
	// 搜索范围改变
　　$('#projectList').change(function(){  
　　　　var pmCode=$('#projectList').val();
	if("1"==pmCode){
		$("#modelIdentCodeList").val("1").attr("disabled","disabled");
		$("#systemCodeList").val("1").attr("disabled","disabled");
		$("#subSystemCodeList").val("1").attr("disabled","disabled");
		$("#assyCodeList").val("1").attr("disabled","disabled");
		$("#infoCodeList").val("1").attr("disabled","disabled");
		
	}
	else{	
		$("#modelIdentCodeList").removeAttr("disabled");
	$.ajax({
			url:'/ietm/getModelIdentCodeList',
			data:{pmCode:pmCode},
			success:function(data){
			for(var i in data){             
	            $("#modelIdentCodeList").append("<option value="+data[i].modelIdentCode+">"+data[i].modelIdentCode+"</option>");
	        	}
			}
		});
	}

　　});
	//型号识别码改变
$("#modelIdentCodeList").change(function(){
	var modelIdentCode=$('#modelIdentCodeList').val();
	if("1"==modelIdentCode){
		$("#systemCodeList").val("1").attr("disabled","disabled");
		$("#subSystemCodeList").val("1").attr("disabled","disabled");
		$("#assyCodeList").val("1").attr("disabled","disabled");
		$("#infoCodeList").val("1").attr("disabled","disabled");
	}
	else{
		$("#systemCodeList").removeAttr("disabled");
	$.ajax({
		url:'/ietm/getSystemCodeList',
		data:{pmCode:$('#projectList').val(),modelIdentCode:modelIdentCode},
		success:function(data){
			for(var i in data){
				$("#systemCodeList").append("<option value="+data[i].systemCode+">"+data[i].systemCode+"</option>")
			}
		}
	});
	}
});
//系统改变
$("#systemCodeList").change(function(){
	var systemCode=$('#systemCodeList').val();
	if("1"==systemCode){
		$("#subSystemCodeList").val("1").attr("disabled","disabled");
		$("#assyCodeList").val("1").attr("disabled","disabled");
		$("#infoCodeList").val("1").attr("disabled","disabled");
	}
	else{
		$("#subSystemCodeList").removeAttr("disabled");
	$.ajax({
		url:'/ietm/getSubSystemCodeList',
		data:{pmCode:$('#projectList').val(),modelIdentCode:$('#modelIdentCodeList').val(),systemCode:systemCode},
		success:function(data){
			for(var i in data){
				$("#subSystemCodeList").append("<option value="+data[i].subSystemCode+">"+data[i].subSystemCode+"</option>")
			}
		}
	});
	}
});
//分系统改变
$("#subSystemCodeList").change(function(){
	var subSystemCode=$('#subSystemCodeList').val();
	if("1"==subSystemCode){
		$("#assyCodeList").val("1").attr("disabled","disabled");
		$("#infoCodeList").val("1").attr("disabled","disabled");
	}
	else{
		$("#assyCodeList").removeAttr("disabled");
	$.ajax({
		url:'/ietm/getAssyCodeList',
		data:{pmCode:$('#projectList').val(),modelIdentCode:$('#modelIdentCodeList').val(),systemCode:$('#systemCodeList').val(),subSystemCode:subSystemCode},
		success:function(data){
			for(var i in data){
				$("#assyCodeList").append("<option value="+data[i].assyCode+">"+data[i].assyCode+"</option>")
			}
		}
	});
	}
});
//单元改变
$("#assyCodeList").change(function(){
	var assyCode=$('#assyCodeList').val();
	if("1"==assyCode){
		$("#infoCodeList").val("1").attr("disabled","disabled");
	}
	else{
		$("#infoCodeList").removeAttr("disabled");
	$.ajax({
		url:'/ietm/getInfoCodeList',
		data:{pmCode:$('#projectList').val(),modelIdentCode:$('#modelIdentCodeList').val(),systemCode:$('#systemCodeList').val(),subSystemCode:$('#subSystemCodeList').val(),assyCode:assyCode},
		success:function(data){
			for(var i in data){
				$("#infoCodeList").append("<option value="+data[i].infoCode+">"+data[i].infoCode+"</option>")
			}
		}
	});
	}
});
//信息码改变
/*$("#infoCodeList").change(function(){
	var infoCode=$('#infoCodeList').val();
	$.ajax({
		url:'/ietm/getSystemCodeList',
		data:{pmCode:$('#projectList').val(),modelIdentCode:modelIdentCode},
		success:function(data){
			for(var i in data){
				$("#modelIdentCodeList").append("<option value="+data.modelIdentCode+">"+data.modelIdentCode+"</option>")
			}
		}
	});
});*/

});
$.fn.serializeObject = function(){
	var o = {};
	var a = this.serializeArray();
	$.each(a, function() {
		if (o[this.name] !== undefined) {
			if (!o[this.name].push) {
				o[this.name] = [o[this.name]];
			}
			o[this.name].push(this.value || '');
		} else {
			o[this.name] = this.value || '';
		}
	});
	return o;
};
function allSearch(){
	 var form1=$("#userHelpSearch").serializeObject();
		$.get("/data-retrieval", form1,function(result){
		    if (result.code == "403") {
	            $.Zebra_Dialog('<div class="prompt"><div class="success-icon"></div><div class="success-title">没有权限</div></div>', {
	                'title': '提示',
	                'buttons': ['确定']
	            });
	        } else {
	          $("body").html(result);
	        }
		  });
} 
